package com.apes.fn.scm.retailOrder.service.retailProcess.process;

import com.apes.fn.scm.retailOrder.model.RetailOrder;
import com.apes.fn.scm.retailOrder.service.retailProcess.CommonRetailDataProcess;
import com.apes.framework.util.MapUtil;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * e保养+ 退回处理
 * e保养+ 退回不走场景流，单独执行退回的逻辑
 *
 * @Author wuq
 * @Date 2021-9-23
 */
@Service
public class EPlusReturnProcess extends CommonRetailDataProcess {

    @Override
    public void beforeSave(RetailOrder retailOrder) {
        beforeProcess(retailOrder, this::updateScene);
    }

    private void updateScene(RetailOrder retailOrder) {
        retailOrder.setScene(null);
    }

    @Override
    public void afterSave(RetailOrder retailOrder) {
        // 通过写入凭证回调 retailService 中的凭证完成方法写入记账日期
        invoke("retail.coupon.returnVoucher", MapUtil.mapped(retailOrder));
    }

    @Override
    public boolean support(String orderType) {
        return "ePlus_Return".equals(orderType);
    }
}
